#!/usr/bin/env python
# -*- coding:utf-8 -*-
import tornado.web
from base import BaseHandler


class IndexHandler(BaseHandler):
    def get(self):
        if self.get_argument('name', None) == 'test':
            self.session['is_login'] = True
            self.session['name'] = self.get_argument('name')
        else:
            self.write('登录失败, 请重新登录!')


class AdminHandler(BaseHandler):
    def get(self):
        if self.session['is_login']:
            self.write('欢迎%s回来. ' % (self.session['name'],))
        else:
            self.redirect('/index')